home *** CD-ROM | disk | FTP | other *** search
/ The Complete Utilities To…ka 501 Killer Utilities! / 501 Killer Utilities! (Macworld July 1995).cdr / Programming / OutOfPhase1.1 Source / OutOfPhase Folder / FilterNull.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-01-03  |  3.1 KB  |  100 lines  |  [TEXT/KAHL]

  1. /* FilterNull.c */
  2. /*****************************************************************************/
  3. /*                                                                           */
  4. /*    Out Of Phase:  Digital Music Synthesis on General Purpose Computers    */
  5. /*    Copyright (C) 1994  Thomas R. Lawrence                                 */
  6. /*                                                                           */
  7. /*    This program is free software; you can redistribute it and/or modify   */
  8. /*    it under the terms of the GNU General Public License as published by   */
  9. /*    the Free Software Foundation; either version 2 of the License, or      */
  10. /*    (at your option) any later version.                                    */
  11. /*                                                                           */
  12. /*    This program is distributed in the hope that it will be useful,        */
  13. /*    but WITHOUT ANY WARRANTY; without even the implied warranty of         */
  14. /*    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          */
  15. /*    GNU General Public License for more details.                           */
  16. /*                                                                           */
  17. /*    You should have received a copy of the GNU General Public License      */
  18. /*    along with this program; if not, write to the Free Software            */
  19. /*    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.              */
  20. /*                                                                           */
  21. /*    Thomas R. Lawrence can be reached at tomlaw@world.std.com.             */
  22. /*                                                                           */
  23. /*****************************************************************************/
  24.  
  25. /* Based on material from pages 184-190 of */
  26. /* Dodge, Charles and Jerse, Thomas A. */
  27. /* Computer Music:  Synthesis, Composition, and Performance */
  28. /* Schirmer Books, New York, 1985 */
  29.  
  30. #include "MiscInfo.h"
  31. #include "Audit.h"
  32. #include "Debug.h"
  33. #include "Definitions.h"
  34.  
  35. #include "FilterNull.h"
  36. #include "Memory.h"
  37.  
  38.  
  39. struct FilterNullRec
  40.     {
  41.         /* link */
  42.         FilterNullRec*            Next;
  43.     };
  44.  
  45.  
  46. static FilterNullRec*            FreeList = NIL;
  47.  
  48.  
  49. /* flush free list */
  50. void                                            FlushCachedFilterNullStuff(void)
  51.     {
  52.         while (FreeList != NIL)
  53.             {
  54.                 FilterNullRec*            Temp;
  55.  
  56.                 Temp = FreeList;
  57.                 FreeList = FreeList->Next;
  58.                 ReleasePtr((char*)Temp);
  59.             }
  60.     }
  61.  
  62.  
  63. /* create a new filter record */
  64. FilterNullRec*                        NewFilterNull(void)
  65.     {
  66.         FilterNullRec*                    Filter;
  67.  
  68.         if (FreeList != NIL)
  69.             {
  70.                 Filter = FreeList;
  71.                 FreeList = FreeList->Next;
  72.             }
  73.          else
  74.             {
  75.                 Filter = (FilterNullRec*)AllocPtrCanFail(sizeof(FilterNullRec),"FilterNullRec");
  76.                 if (Filter == NIL)
  77.                     {
  78.                         return NIL;
  79.                     }
  80.             }
  81.         return Filter;
  82.     }
  83.  
  84.  
  85. /* dispose filter record */
  86. void                                            DisposeFilterNull(FilterNullRec* Filter)
  87.     {
  88.         CheckPtrExistence(Filter);
  89.         Filter->Next = FreeList;
  90.         FreeList = Filter;
  91.     }
  92.  
  93.  
  94. /* apply filter to a sample value */
  95. float                                            ApplyFilterNull(FilterNullRec* Filter, float Xin)
  96.     {
  97.         CheckPtrExistence(Filter);
  98.         return Xin;
  99.     }
  100.